package net.lab1024.sa.admin.module.business.erp.mmo.controller;

import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.PrfordaAddForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.PrfordaQueryForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.PrfordaUpdateForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.vo.PrfordaVO;
import net.lab1024.sa.admin.module.business.erp.mmo.service.PrfordaService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 产品送检单行 Controller
 *
 * @Author AKITA
 * @Date 2025-08-18 21:57:45
 * @Copyright AKITA
 */

@RestController
@Tag(name = "产品送检单行")
public class PrfordaController {

    @Resource
    private PrfordaService prfordaService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/prforda/queryPage")
    @SaCheckPermission("prforda:query")
    public ResponseDTO<PageResult<PrfordaVO>> queryPage(@RequestBody @Valid PrfordaQueryForm queryForm) {
        return ResponseDTO.ok(prfordaService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/prforda/add")
    @SaCheckPermission("prforda:add")
    public ResponseDTO<String> add(@RequestBody @Valid PrfordaAddForm addForm) {
        return prfordaService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/prforda/update")
    @SaCheckPermission("prforda:update")
    public ResponseDTO<String> update(@RequestBody @Valid PrfordaUpdateForm updateForm) {
        return prfordaService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/prforda/batchDelete")
    @SaCheckPermission("prforda:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return prfordaService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/prforda/delete/{id}")
    @SaCheckPermission("prforda:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return prfordaService.delete(id);
    }
}
